package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Conclusion;
import com.tanhua.model.mongo.Dimensions;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ConclusionVo {


    private String conclusion;
    private String cover;

    private List<Dimensions> dimensions;

    private List<UserVo> similarYou;

    public static ConclusionVo init(Conclusion conclusion, List<Dimensions> dimensions, List<UserInfo> userInfo){
        ConclusionVo vo = new ConclusionVo();
        if (conclusion!=null){
            vo.setConclusion(conclusion.getConclusionName());
            vo.setCover(conclusion.getCover());
        }

        vo.setDimensions(dimensions);
        List<UserVo> similarYou = new ArrayList<>();
        for (UserInfo info : userInfo) {
            UserVo userVo = new UserVo();
            userVo.setId(info.getId().intValue());
            userVo.setAvatar(info.getAvatar());
            similarYou.add(userVo);
        }

        vo.setSimilarYou(similarYou);

        return vo;
    }
}
